import http from '@/utils/http'

const BASE_URL = '/testing/stressCase'

export interface StressCaseResp {
  id: string
  projectId: string
  moduleId: string
  environmentId: string
  name: string
  description: string
  assertion: string
  relation: string
  stressSourceType: string
  threadGroupConfig: string
  jmxUrl: string
  path: string
  method: string
  query: string
  header: string
  body: string
  bodyType: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface StressCaseDetailResp {
  id: string
  projectId: string
  moduleId: string
  environmentId: string
  name: string
  description: string
  assertion: string
  relation: string
  stressSourceType: string
  threadGroupConfig: string
  jmxUrl: string
  path: string
  method: string
  query: string
  header: string
  body: string
  bodyType: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface StressCaseQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface StressCasePageQuery extends StressCaseQuery, PageQuery {}

/** @desc 查询压测用例列表 */
export function listStressCase(query: StressCasePageQuery) {
  return http.get<PageRes<StressCaseResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询压测用例详情 */
export function getStressCase(id: string) {
  return http.get<StressCaseDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增压测用例 */
export function addStressCase(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改压测用例 */
export function updateStressCase(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除压测用例 */
export function deleteStressCase(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出压测用例 */
export function exportStressCase(query: StressCaseQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
